package top.codedance.iotp.tools.earlyWarning.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class FileTool {
    public static void mkdirs(String path){
        File myTmpDirF = new File(path);
        if(!myTmpDirF.exists()){
            myTmpDirF.mkdirs();
        }
    }

    public static void fromJarCopyFile(InputStream in, String target){
        File wavF = new File(target);
        if(!wavF.exists()){
            try {
                wavF.createNewFile();
                FileOutputStream out = new FileOutputStream(wavF);

                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                }

                in.close();
                out.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
